//    https://ac.nowcoder.com/acm/contest/5026/A



#include <iostream>
using namespace std;

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int h, a, H, A;
        cin >> h >> a >> H >> A;
        if (a >= H)
            cout << -1 << endl;
        else if (h <= A)
            cout << 0 << endl;
        else
        {
            int k = (h - 1) / (((H - 1) / a) * A);
            cout << k << endl;
        }
    }
    return 0;
}